﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp12
{
    public class Linux
    {
        public static void Run()
        {
            //初始化
            InitWiringPI();
            //设置Pin 1 为输出模式
            SetPinModel(1, 1);
            //开始周期性修改Pin 1的高低电瓶
            for (int i = 0; i < 100; i++)
            {
                //置高电平
                SetPinValue(1, 1);
                Thread.Sleep(1000);
                //置低电平
                SetPinValue(1, 0);
                Thread.Sleep(1000);

            }
        }

        [DllImport("libraspberry", EntryPoint = "InitWiringPI")]
        public static extern void InitWiringPI();

        [DllImport("libraspberry", EntryPoint = "SetPinModel")]
        public static extern void SetPinModel(int wiringPoint, int model);

        [DllImport("libraspberry", EntryPoint = "SetPinValue")]
        public static extern void SetPinValue(int wiringPoint, int model);
    }
}
